import request from '@/utils/request'

// 所有列表数据
export function getReportList(data) {
  return request({
    url: '/trainingReport/page',
    method: 'get',
    params: {
      cropId: data.cropId,
      studentId: data.studentId,
      limit: '50',
      page: '1',
      reviewStatus: data.reviewStatus,
      trainingReportName: data.trainingReportName,
      endTime: data.endTime,
      startTime: data.startTime
    }
  })
}

// 学生具体实训报告
export function getReportDetail(data) {
  return request({
    url: '/trainingReport/teachertView',
    method: 'get',
    params: {
      trainingReportId: data.trainingReportId
    }
  })
}

// 增加一条实训报告
export function AddReportDetail(dataform, dataquery) {
  return request({
    url: '/trainingReport/addTrainingReport',
    method: 'post',
    params: {
      studentId: dataquery.studentId,
      batch: dataquery.batch,
      cropId: dataquery.cropId,
      trainingReportName: dataquery.trainingReportName
    },
    data: dataform
  })
}

// 获取修改一条实训报告   get
export function getModifyReport(data) {
  return request({
    url: '/trainingReport/studentView',
    method: 'get',
    params: {
      trainingReportId: data.trainingReportId
    }
  })
}

// 修改一条实训报告   post
export function postModifyReport(dataform, dataquery) {
  return request({
    url: '/trainingReport/changeReportByStudent',
    method: 'post',
    params: dataquery,
    data: dataform
  })
}

// 老师导出实训报告
export function exportReportData(data) {
  return request({
    url: '/trainingReport/exportReport',
    method: 'get',
    responseType: 'blob',
    params: data,
    paramsSerializer: function(params) {
      const classIds = params.classIds.map(_ => `classIds%5B%5D=${_}`).join('&')
      return `${classIds}&cropId=${data.cropId}&teacherId=${data.teacherId}`
    }
  })
}

// 删除一条实训报告
export function deleteReportDetail(data) {
  return request({
    url: '/trainingReport/deleteTrainingReport',
    method: 'post',
    params: {
      trainingReportId: data.trainingReportId
    }
  })
}

// 批量删除实训报告
export function deleteMoreReport(data) {
  return request({
    url: '/trainingReport/deleteTrainingReports',
    method: 'post',
    params: {
      trainingReportIds: data
    }
  })
}

// 老师批改改学生实训报告
export function ModifyReport(data) {
  return request({
    url: '/trainingReport/changeReportByTeacher',
    method: 'post',
    params: {
      comments: data.comments,
      score: data.score,
      trainingReportId: data.trainingReportId
    }
  })
}
